package cn.ike.service.redis.impl;

import cn.ike.domain.system.Module;
import cn.ike.service.redis.RedisService;
import cn.ike.utils.JedisUtils;
import com.alibaba.fastjson.JSONArray;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.stereotype.Service;
import redis.clients.jedis.Jedis;

import java.util.List;

@Service
public class RedisServiceImpl implements RedisService {
    @Override
    public List<Module> findAll() {
        // 从redis中获取所有权限
        Jedis jedis = JedisUtils.getJedis();
        String allModules = jedis.get("allModules");
        JSONArray objects = JSONArray.parseArray(allModules);
        List<Module> moduleList = objects.toJavaList(Module.class);
        jedis.close();
        return moduleList;
    }
}
